<template>
	<view>
		<u-tabs :list="list" :is-scroll="false" :current="current" @change="change"></u-tabs>
		<view v-if="current=='0'">
			<view class="item" v-for="(item,index) in fail" :key="item.id">
				<view>
					<view class="name">
					<view>名称：{{item.name}}</view>
					</view>
					<view>
						<view class="">
							地点：{{item.place}}
						</view>
					</view>
					<view>
						<view class="">
							描述：{{item.description}}
						</view>
					</view>
					<view>
						<view class="">
							上报人：{{item.reportPeople}}&nbsp;&nbsp;&nbsp;联系方式：{{item.phone}}
						</view>
					</view>
					<view>
						<view class="">
							上报时间：{{item.reportDate}}
						</view>
					</view>
					<view>
						当前状态：
						<span v-if="item.dealStatus=='1'">待验证</span>
							<button @click="report(item)">重新上报</button>
					</view>
				</view>
			</view>
		</view>
		<view v-if="current=='1'">
			<view class="item" v-for="(item,index) in success" :key="item.id">
				<view>
					<view class="name">
					<view>名称：{{item.name}}</view>
					</view>
					<view>
						<view class="">
							地点：{{item.place}}
						</view>
					</view>
					<view>
						<view class="">
							描述：{{item.description}}
						</view>
					</view>
					<view>
						<view class="">
							上报人：{{item.reportPeople}}&nbsp;&nbsp;&nbsp;联系方式：{{item.phone}}
						</view>
					</view>
					<view v-if="item.dealStatus=='3'|| item.dealStatus=='4'">
						<view>处理人：{{item.header.name}}---联系方式：{{item.header.phone}}</view>
					</view>
					<view>
						<view class="">
							上报时间：{{item.reportDate}}<span v-if="item.dealStatus=='4'">---完成时间：{{item.endDate}}</span>
						</view>
					</view>
					
					<view>
						当前状态：
						<span v-if="item.dealStatus=='2'">待处理</span>
						<span v-if="item.dealStatus=='3'">待验证</span>
						<span v-if="item.dealStatus=='4'">已完成</span>
					</view>
				</view>
			</view>
		</view>
		<view v-if="current=='2'">
			
			<u-input v-model="phone" placeholder="电话" :border="true"></u-input>
			<button @click="getUndo()">查询</button>
			<view class="item" v-for="(item,index) in hiddenUndoes" :key="item.id">
				<view>
					<view class="name">
						<view>名称：{{item.name}}</view>
					</view>
					<view>
						<view class="">
							上报人：{{item.reportPeople}}&nbsp;&nbsp;&nbsp;联系方式：{{item.phone}}
						</view>
					</view>
					<view>
						<view class="">
							上报时间：{{item.reportDate}}&nbsp;&nbsp;&nbsp;过期时间：{{item.expirationDate}}
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
	

</template>
<script>
	export default {
		data() {
			return {
				fail:[],
				success:[],
				hiddenTroubles:[],
				hiddenTroubleVO:{
					id:0,
					name:"",
					place:"",
					description:"",
					reportDate:"",
					hiddenTroubleTypeId:"",
					reportPeople:"",
					phone:"",
				},
				hiddenUndo:{
					id:0,
					name:"",
					reportDate:"",
					reportPeople:"",
					expirationDate:"",
					phone:""
				},
				phone:"",
				hiddenUndoes:[],
				list: [{
					name: '待审核'
				}, {
					name: '已通过'
				},{
					name: '未处理'
				}],
				current: 0
			}
		},
		methods: {
			report(item){
				console.log(item)
				
				this.$axios.post("/")
			},
			change(index) {
				this.current = index;
			},
			getFail(){
				let hiddenTroubleVo={
					id:0,
					name:"",
					place:"",
					description:"",
					reportDate:"",
					hiddenTroubleTypeId:0,
					reportPeople:"",
					headerId:0,
					dealStatus:"1",
					phone:"18177407649",
					pageNum:1,
					pageSize:100
				}
				//返回的是pageInfo
				this.$axios.post("/api/xjh/hidden/getByCondition",hiddenTroubleVo).then(r=>{
				    if(r.data.code==200){
				    this.fail=r.data.data.list;
				    console.log(this.fail)
				    }
				})
			},
			getUndo(){
				let hiddenUndo={
					phone:this.phone
				}
				this.$axios.post("/api/xjh/undo/getByPhone",hiddenUndo).then(r=>{
					if(r.data.code==200){
						this.hiddenUndoes=r.data.data.list;
						console.log(r.data.data.list);
					}
				})
			},
			getSuccess(){
				let hiddenTroubleVo={
					id:0,
					name:"",
					place:"",
					description:"",
					reportDate:"",
					hiddenTroubleTypeId:0,
					reportPeople:"",
					headerId:0,
					dealStatus:"1",
					phone:"18177407649",
				}
				//返回的是list
				this.$axios.post("/api/xjh/hidden/getByStatus",hiddenTroubleVo).then(r=>{
				    if(r.data.code==200){
				    this.success=r.data.data;
				    console.log(this.success)
				    }
				})
			},
		},
		created() {
			this.getFail();
			this.getSuccess();
		}
	}
</script>